from GCForest import gcForest
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
import pandas as pd
import numpy as np

data = pd.read_csv('F:\\bishe\\data1.csv')
X = data.iloc[:, 0:2297]
X = np.array(X)
y = data.iloc[:, -1:]
y = np.array(y)
X_tr, X_te, y_tr, y_te = train_test_split(X, y, test_size=0.25)
print(pd.DataFrame(X_tr).head())

# 注意里边的参数设置，详细的参数意义
# 可以参考源码中的参数解释
gcf = gcForest(shape_1X=2, window=1, tolerance=0.0)
gcf.fit(X_tr, pd.DataFrame(y_tr).values.ravel())

# 类别预测
pred_X = gcf.predict(X_te)
print(pred_X)
print(y_te)
pred_X_prob = gcf.predict_proba(X_te)
print(pred_X_prob)

# 模型评估
accuracy = accuracy_score(y_true=y_te, y_pred=pred_X)
print('gcForest accuracy : {}'.format(accuracy))

# 模型保存
# import joblib
# joblib.dump(gcf, 'my_iris_model.sav')
# print('model dumped successfully!)




